/**
 * @author Farah
 */

// *********** Extra variable needs to be replaced by DB function call if home exists
var isHomeFound;

/**
 * Display Modal dialog to pick home location for first time user
 */
displayModal = function() {
	console.log('inside display modal');
	$("#pickHomeDiv").dialog({
		buttons : [{
			text : "Pick Home",
			click : function() {
				pickHomeOnMap();
				$(this).dialog("close");

			}
		}]
	});

	$("#pickHomeDiv").dialog();
}
displayIconOnMap = function(setIcon, marker) {

	//console.log(marker.position.lat());
	var lat = marker.lat();
	var lng = marker.lng();

	new google.maps.Marker({
		icon : setIcon, //"https://google-maps-icons.googlecode.com/files/home.png",
		map : map,
		position : new google.maps.LatLng(lat, lng),
		title : "house"
	});

	map.setCenter(this.position);
};

// Returns a random number between min (inclusive) and max (exclusive)
getRandomArbitrary = function(min, max) {
	var rnd = Math.random() * (max - min) + min;
	return rnd;
}

/*Deprecated function not needed remove when cleaning up code*/
isHomeInDB = function() {

	var tempData = false;

	$.getJSON("php/getHomeLatLng.php", {
		format : "json"
	}, function(data) {
		if ( typeof data.lat != 'undefined') {

			tempData = true;

		}
	}).done(function() {
		console.log("inside if typeof data.lat " + tempData);
		isHomeFound = tempData;
		return tempData;
	});

}